<template>
  <div class="main">
    <div class="main-header">
      <h2 class="header-title font-24">品牌洞察</h2>
      <p class="header-desc font-14"> 精选12个行业知名品牌，可查看各平台品牌的声量情况. </p>
      <p class="header-desc font-14"> 聚合展现为品牌发声的视频和红人，追踪分析品牌最新社媒宣传动态，学习品牌传播打法，一键收藏品牌使用的红人并为己用。 </p>
    </div>

    <div style="padding: 0 24px;">
      <div class="search flex-between flex-align-items-center">
        <div class="search-left flex flex-align-items-center">
          <div class="search-input">
            <el-input placeholder="品牌词搜索"></el-input>
            <i class="iconfont icon-sousuo pointer"></i>
          </div>
          <cate :check="form.cate" @change="cateChange"></cate>
          <el-popover placement="bottom" :width="170" trigger="click">
            <template #reference>
              <p class="filter-btn flex-center flex-align-items-center pointer">
                <i class="iconfont icon-paixu"></i>
              </p>
            </template>
            <div class="sort-list">
              <p v-for="(item, index) in sortList" :key="index" class="font-14 pointer">{{ item.name }}</p>
            </div>
          </el-popover>
        </div>
        <div class="search-right flex">
          <p class="font-16 pointer" @click="toPath('/myLock')">我的解锁</p>
          <p class="font-16 pointer" @click="toPath('/myFocus')">我的关注</p>
        </div>
      </div>

      <div class="list">
        <item v-for="item in list" :key="item.id" :item="item"></item>
      </div>

      <div class="pagination flex flex-align-items-center" style="justify-content: end;height: 64px;">
        <el-pagination :page-sizes="[10, 20, 50, 100]" layout="prev, pager, next, total" :total="form.total" />
      </div>
    </div>
  </div>
</template>

<script setup>
import Cate from './components/cate.vue';
import Item from './components/item.vue';
import { ref } from 'vue';
import { useRouter } from 'vue-router';

const router = useRouter();

const sortList = [
  {
    name: '推广红人数倒序',
    value: 1
  },
  {
    name: '推广视频/帖子数倒序',
    value: 2
  },
  {
    name: '品牌互动率倒序',
    value: 3
  },
  {
    name: '曝光量倒序',
    value: 4
  }
];

const form = ref({
  cate: [],
  total: 100
});
const list = ref([
  {
    id: 1,
    follow: false,
    Unlock: true,
    name: 'xxx',
    img: 'https://www.wotohub.com/static/img/koc_default_man.8132f247.svg',
    cate: '数码电器',
    count: 11111
  },
  {
    id: 2,
    follow: true,
    name: 'xxx',
    img: 'https://www.wotohub.com/static/img/koc_default_man.8132f247.svg',
    cate: '数码电器',
    count: 11111
  }
]);

const cateChange = e => {
  form.value.cate = e;
};
const toPath = e => {
  router.push(e);
}
</script>

<style lang="less" scoped>
.main {
  height: calc(100vh - 64px);
  overflow-y: auto;
  background: #fff;
}

.main-header {
  padding: 24px 0 32px 40px;
  background: #ffeef2;

  .header-title {
    color: #12172c;
    line-height: 32px;
    letter-spacing: 1px;
    margin-bottom: 8px;
  }

  .header-desc {
    color: #333;
    line-height: 16px;
    letter-spacing: 1px;

    &:last-child {
      margin-top: 8px;
    }
  }
}

.search {
  padding: 24px 0;

  .search-left {
    .search-input {
      width: 320px;
      height: 44px;
      position: relative;

      &::v-deep {
        .el-input {
          width: 100%;
          height: 44px;
        }
      }

      i {
        color: @main-color;
        position: absolute;
        right: 14px;
        top: 14px;
        z-index: 10;
      }
    }

    .filter-btn {
      width: 48px;
      height: 44px;
      border-radius: 10px;
      border: 1px solid #f2f2f2;
      margin-left: 16px;

      &:hover {
        background: #f8f8f8;
      }

      i {
        color: #a1a1a1;
        font-size: 20px;
      }
    }
  }

  .search-right {
    p {
      width: 106px;
      height: 44px;
      border-radius: 8px;
      margin-left: 10px;
      text-align: center;
      line-height: 42px;
      border: 1px solid @main-color;
      color: @main-color;

      &:hover {
        background: @main-color;
        color: #fff;
      }
    }
  }
}

.list {
  display: grid;
  justify-content: space-between;
  grid-column-gap: 12px;
  grid-row-gap: 12px;
  grid-template-columns: repeat(4, 1fr);
}

.sort-list {
  padding: 6px 0;

  p {
    height: 34px;
    padding-left: 20px;
    line-height: 34px;
    color: #606266;

    &:hover {
      background: #f5f7fa;
    }
  }
}
</style>
